package day5;

public class ch4 {

    public void flatten(TreeNode root) {

        TreeNode node = root;
        while (node!=null){
            if(node.left!=null){
                TreeNode l = node.left;
                while(l.right!=null){
                    l = l.right;
                }
                l.right=node.right;
                node.right = node.left;
                node.left = null;
            }
            node = node.right;
        }
    }


}
